home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / tsptp.zip / FLOAT.PAS < prev    next >
Pascal/Delphi Source File  |  1993-04-09  |  3KB  |  92 lines

  1. (******************************************************************************)
  2. (*                                 RMATH.PAS                                  *)
  3. (*                            Real Math Benchmark.                            *)
  4. (******************************************************************************)
  5.  
  6. PROGRAM FLOAT(Output);
  7.  
  8. (******************************************************************************)
  9. (*                                TIMING                                      *)
  10. (******************************************************************************)
  11.  
  12. (*$IFNDEF TopSpeed *)
  13.  (*%F TRUE   *** Compile for Turbo Pascal ***)
  14.   USES TPBench;
  15.  (*%E*)
  16. (*$ELSE     *** Compile for TopSpeed Pascal ***)
  17.   IMPORT TSBench *;
  18. (*$ENDIF *)
  19.  
  20. (******************************************************************************)
  21.  
  22.   CONST
  23.     CONST1 = 3.141597E0;
  24.     CONST2 = 1.7839032E4;
  25.  
  26.   VAR
  27.     C : BmReal;
  28.  
  29.   PROCEDURE FloatProc;
  30.     VAR
  31.       I    : BmInt;
  32.       A, B : BmReal;
  33.   BEGIN
  34.  
  35.     A := CONST1;
  36.     B := CONST2;
  37.  
  38.     FOR I := 1 TO 10000 DO
  39.     BEGIN
  40.       C := A * B;
  41.       C := C / A;
  42.       C := A * B;
  43.       C := C / A;
  44.       C := A * B;
  45.       C := C / A;
  46.       C := A * B;
  47.       C := C / A;
  48.       C := A * B;
  49.       C := C / A;
  50.       C := A * B;
  51.       C := C / A;
  52.       C := A * B;
  53.       C := C / A
  54.     END;
  55.  
  56.   END;
  57.  
  58. BEGIN
  59.   WriteLn('Float Benchmark');
  60.  
  61. (******************************************************************************)
  62. (*  Compute the looping overhead.  The Dummy procedure must have some side-   *)
  63. (*  effect so that it is not optimised out of existence.                      *)
  64. (******************************************************************************)
  65.  
  66.   StartTimer;                                   (* Start the clock.           *)
  67.  
  68.   REPEAT
  69.     Dummy;
  70.   UNTIL NullTimesUp;
  71.  
  72. (******************************************************************************)
  73. (*  Now run the benchmark.  Note that the Dummy procedure is also called so   *)
  74. (*  that we can eliminate its overhead from the looping overhead.             *)
  75. (******************************************************************************)
  76.  
  77.   StartTimer;                                   (* Start the clock.           *)
  78.  
  79.   REPEAT
  80.     FloatProc;
  81.     Dummy
  82.   UNTIL BenchTimesUp;
  83.  
  84. (******************************************************************************)
  85.  
  86.   ReportTimes;
  87.  
  88.   WriteLn;
  89.   WriteLn('Result: C = ', C:10);
  90.  
  91. END.
  92.